package com.example.demo.pojo;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

//员工表
@Entity // 声明实体类(和数据表映射的类)
@Table(name ="employee") // 配置实体类和表的映射关系,省略默认小写
public class Employee {

	@Id // 声明主键的配置
	@GeneratedValue(strategy = GenerationType.IDENTITY) // 配置主键的生成策略
	private Integer id;
	
	@Column// 配置属性和字段的映射关系，省略默认列名就是属性
	private String lastName;
	@Column
	private String email;
	@Column
	private Integer gender; // 0:女 1:男
	//@Column
	@ManyToOne
	private Department department;
	@Column
	private Date birth;

	public Employee() {
	}

	public Employee(Integer id, String lastName, String email, Integer gender, Department department) {
		this.id = id;
		this.lastName = lastName;
		this.email = email;
		this.gender = gender;
		this.department = department;
		this.birth = new Date();
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Integer getGender() {
		return gender;
	}

	public void setGender(Integer gender) {
		this.gender = gender;
	}

	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	public Date getBirth() {
		return birth;
	}

	public void setBirth(Date birth) {
		this.birth = birth;
	}

	@Override
	public String toString() {
		return "Employee{" + "id=" + id + ", lastName='" + lastName + '\'' + ", email='" + email + '\'' + ", gender="
				+ gender + ", department=" + department + ", birth=" + birth + '}';
	}
}
